package service;

import java.util.Date;
import java.util.List;

import entity.Employee;
import entity.Union;
import entity.UnionDue;

public class UnionAssociationService implements AssociationService {
	private Date lastPayDay;
	private Employee employee;
	public UnionAssociationService(Employee employee,Date lastPayDay) {
		super();
		this.employee=employee;
		this.lastPayDay=lastPayDay;
	}

	@Override
	public float CalcCosts() {
		List<UnionDue> list=((Union)employee.getAssociation()).getUnionDues();
		float costs=0;
		for(int i=0;i<list.size();i++){
			if(lastPayDay==null||(list.get(i).getDate().after(lastPayDay))){
				costs+=list.get(i).getAmount();
			}
		}
		return ((Union)employee.getAssociation()).getUnion_tax()+costs;
	}
}
